# FrontOfQueuePointer  指向最前面，第一个元素，即下一个移除队列的元素
# EndOfQueuePointer 指向最后面一个元素

def addToQueue(item,EndOfQueuePointer):
    global NumberinQueue
    if NumberinQueue < MaxQueueSize:
        EndOfQueuePointer+=1
        if EndOfQueuePointer>MaxQueueSize-1:
            EndOfQueuePointer = 0
        queue[EndOfQueuePointer] = item
        NumberinQueue +=1
    else:
        print("out of range")
    return EndOfQueuePointer

def remove(FrontOfQueuePointer):
    global NumberinQueue
    if NumberinQueue>0:
        queue[FrontOfQueuePointer] = None
        NumberinQueue -=1
        FrontOfQueuePointer+=1
        if FrontOfQueuePointer>MaxQueueSize-1:
            FrontOfQueuePointer = 0
    return FrontOfQueuePointer
#
# def test():
#     queue[1]=0
if __name__ == '__main__':
    MaxQueueSize = 4
    queue = [None for i in range(MaxQueueSize)]
    FrontOfQueuePointer = 0
    EndOfQueuePointer = -1
    NumberinQueue = 0
    print(queue)
    EndOfQueuePointer = addToQueue(5,EndOfQueuePointer)
    EndOfQueuePointer = addToQueue(6,EndOfQueuePointer)
    EndOfQueuePointer = addToQueue(7,EndOfQueuePointer)
    EndOfQueuePointer = addToQueue(8,EndOfQueuePointer)
    FrontOfQueuePointer = remove(FrontOfQueuePointer)
    EndOfQueuePointer = addToQueue(9, EndOfQueuePointer)
    print(queue)



